package cn.boundtw2.Stream01;

import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

/*
          void write(byte[] b) 将 b.length 个字节从指定的 byte 数组写入此输出流。
          void write(byte[] b, int off, int len) 将指定 byte 数组中从偏移量 off 开始的 len 个字节写入此输出流。
 */
public class Demo02OutputStream {
    public static void main(String[] args) throws IOException {
        FileOutputStream fos = new FileOutputStream("IOliu\\b.txt");
        fos.write(48);
        fos.write(48);
        fos.write(48);
        byte[] bytes = {65,66,67,68};//ABCD
        //byte[] bytes = {-65,-66,-67,68,69};//烤紻E

        fos.write(bytes);
        fos.write(bytes,1,2);//BC

        byte[] bytes1 = "你好".getBytes();//把字符串转化为bytes
        System.out.println(bytes1);
        fos.write(bytes1);//你好
        fos.close();
    }
}
